-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Validate swagger API schema in integ tests #5524
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Manciukic
wants to merge
6
commits into
firecracker-microvm:main
Choose a base branch
from
Manciukic:validate-api-swagger
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Validate swagger API schema in integ tests #5524
Manciukic
wants to merge
6
commits into
firecracker-microvm:main
from
Manciukic:validate-api-swagger
+352
−13
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5524 +/- ##
=======================================
Coverage 82.88% 82.88%
=======================================
Files 270 270
Lines 27784 27784
=======================================
Hits 23028 23028
Misses 4756 4756
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Add missing pmem field from vm config response. Signed-off-by: Riccardo Mancini <[email protected]>
We mistakenly added it as `output_path` rather than `serial_out_path`. Signed-off-by: Riccardo Mancini <[email protected]>
b375678 to
3f2089e
Compare
The custom CPU templates were just a plain object with no definition of their fields. This patch adds specific definition for all its fields. Signed-off-by: Riccardo Mancini <[email protected]>
To implement a strict API validation, let's annotate when extra fields are actually expected. Signed-off-by: Riccardo Mancini <[email protected]>
Validate that all requests we do to the API are conformant to the swagger, and that all responses are also conformant. This check is strict, meaning no extra fields are allowed to catch problems where there is a typo in the swagger. We only check successful requests as we don't want to fail when we try to send a bad request on purpose. If the request is successful, then it means the schema should have been valid. Signed-off-by: Riccardo Mancini <[email protected]>
3f2089e to
93fddc4
Compare
11 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changes
This change adds a validation for the Swagger schema by verify that every successful request and response to the server is strictly (no extra fields allowed) conformant to the schema.
This new validation allowed me to find a couple of latent bugs:
PUT /serialtakes aserial_out_path, not anoutput_pathPUT /cpu-configdidn't specify a specific schema for the parametersGET /vm-configwas missingpmemSince for this to work we need the check to be strict, I also explicitly added
additionalParameters: truewhere additial fields are expected (this is the default for Swagger).Reason
Continuously verify that the schema matches the Firecracker API in the integration tests.
License Acceptance
By submitting this pull request, I confirm that my contribution is made under
the terms of the Apache 2.0 license. For more information on following Developer
Certificate of Origin and signing off your commits, please check
CONTRIBUTING.md.PR Checklist
tools/devtool checkbuild --allto verify that the PR passesbuild checks on all supported architectures.
tools/devtool checkstyleto verify that the PR passes theautomated style checks.
how they are solving the problem in a clear and encompassing way.
in the PR.
CHANGELOG.md.Runbook for Firecracker API changes.
integration tests.
TODO.rust-vmm.